﻿using System.Threading.Tasks;
using Magicodes.ExporterAndImporter.Excel.AspNetCore;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NP.BPMReportPlatform.NCRD.Dto;
using Volo.Abp.Application.Dtos;

namespace NP.BPMReportPlatform.NCRD
{
    /// <summary>
    /// 工程接口
    /// </summary>
    [Authorize]
    [ApiController]
    [Route("api/ncrd")]
    public class NCRDController : BPMReportPlatformController
    {
        private readonly INCRDService _ncrdService;

        public NCRDController(INCRDService ncrdService)
        {
            _ncrdService = ncrdService;
        }

        /// <summary>
        ///NCRD委托分析审批流程 查询数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("NCRD/GetAllAsync")]
        public async Task<PagedResultDto<GetNCRDOutput>> GetAllAsync(
            [FromBody] GetNCRDInput input)
        {
            return await _ncrdService.GetAllAsync(input);
        }

        /// <summary>
        /// NCRD委托分析审批流程 导出数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("NCRD/ExportAsync")]
        public async Task<XlsxFileResult<GetNCRDOutput>> ExportAsync(
            [FromBody] GetNCRDInput input)
        {
            var rst = await _ncrdService.ExportAsync(input);
            return new XlsxFileResult<GetNCRDOutput>(rst, "导出Excel");
        }
    }
}